using Game.Component;
using Game.Core;

namespace Game.Manager
{
	public class DepthManager : Singleton<DepthManager>
	{
		public DepthSystem sceneLayer;

		public DepthSystem distLayer;

		public DepthSystem storageBoxLayer;

		public void Init(DepthSystem sceneLayer, DepthSystem distLayer, DepthSystem storageBoxLayer)
		{
			this.sceneLayer = sceneLayer;
			this.sceneLayer.baseNode = this.sceneLayer;
			this.distLayer = distLayer;
			this.distLayer.baseNode = this.distLayer;
			this.storageBoxLayer = storageBoxLayer;
			this.storageBoxLayer.baseNode = this.storageBoxLayer;
		}

		public void AddToSceneLayer(DepthSystem node, DepthType depthType)
		{
			if (sceneLayer != null)
			{
				sceneLayer.AddChildNode(node, depthType);
			}
		}

		public void SortSceneLayer(bool needUpdatePos)
		{
			if (sceneLayer != null)
			{
				sceneLayer.SortSelf(needUpdatePos);
			}
		}

		public void AddToDistLayer(DepthSystem node, DepthType depthType)
		{
			if (distLayer != null)
			{
				distLayer.AddChildNode(node, depthType);
			}
		}

		public void SortDistLayer(bool needUpdatePos)
		{
			if (distLayer != null)
			{
				distLayer.SortSelf(needUpdatePos);
			}
		}

		public void AddToStorageBoxLayer(DepthSystem node, DepthType depthType)
		{
			if (storageBoxLayer != null)
			{
				storageBoxLayer.AddChildNode(node, depthType);
			}
		}

		public void SortStorageBoxLayer(bool needUpdatePos)
		{
			if (storageBoxLayer != null)
			{
				storageBoxLayer.SortSelf(needUpdatePos);
			}
		}

		public void Clear()
		{
			sceneLayer = null;
			distLayer = null;
		}
	}
}
